#ifndef MAPVIEW_H
#define MAPVIEW_H

#include "../external/sync-layer/asynclayer.h"
#include "mapinfo.h"
#include <QVector>
#include <memory>
#include <mutex>

class MapView : public AsyncLayer
{
public:
    MapView();
    ~MapView();

    // 载入地图
    void load();

protected:
    void draw(QPixmap& pixmap) override;

private:
    // 地图列表
    QVector<MapInfo*> map_list;
    // 列表访问锁
    std::mutex map_mtx;

    // 判断是否在窗口内
    bool inBox(const QPointF& point, const QSizeF& size);

    // 写入配置
    void saveMapList();
    // 读取配置
    void readMapList();

};

extern std::shared_ptr<MapView> map_view;

#endif // MAPVIEW_H
